//
//  RoundProgress.m
//  Progress
//
//  Created by hanyazhou on 15/5/27.
//  Copyright (c) 2015年 HYZ. All rights reserved.
//

#import "RoundProgress.h"
@interface RoundProgress()
@property (nonatomic,assign) int type;
@property (nonatomic,assign) float startAngle;//开始角度
@property (nonatomic,assign) float grayEndAngle;//外圈结束角度
@end
@implementation RoundProgress

-(id)initCreateTheCircleWithFrame:(CGRect)frame withStartAngle:(CGFloat)startAngle andEndAngle:(CGFloat)endAngle andTheGrayCicleEndAngle:(CGFloat)grayCicleEndAngle
{
    self = [super initWithFrame:frame];
    if (self)
    {
        self.backgroundColor = [UIColor clearColor];
        
        _startAngle = startAngle;
        _endAngle = endAngle;
        _grayEndAngle = grayCicleEndAngle;
        
    }
    return self;
}

- (void)drawRect:(CGRect)rect {
    
    NSAssert(rect.size.width == rect.size.height, @"目前只支持画圆，所以请确保[[RoundProgress alloc] initWithFrame:CGRectMake(x, x, 200, 200)]  width 和  height  相等");
    /*最外层的边线*/
    UIBezierPath *roundPath1 = [UIBezierPath bezierPathWithArcCenter:CGPointMake(rect.size.width/2, rect.size.height/2) radius:rect.size.width/2-_progressWidth/2 startAngle:_startAngle endAngle:_grayEndAngle clockwise:TRUE];
    roundPath1.lineWidth = 2;
    roundPath1.lineJoinStyle = kCGLineJoinRound;
    roundPath1.lineCapStyle = kCGLineCapRound;
    [[UIColor colorWithRed:229.0f / 255.0f green:229.0f / 255.0f blue:229.0f / 255.0f alpha:1.0f] set];
    [roundPath1 stroke];
   
    /*红色进度*/
    UIBezierPath *bluePath = [UIBezierPath bezierPathWithArcCenter:CGPointMake(rect.size.width/2, rect.size.height/2) radius:rect.size.width/2-_progressWidth/2 startAngle:_startAngle endAngle:_endAngle clockwise:TRUE];
    bluePath.lineWidth = _progressWidth;
    bluePath.lineJoinStyle = kCGLineJoinRound;
    bluePath.lineCapStyle = kCGLineCapRound;
    UIColor *bColor = [UIColor hexStringToColor:RED_COLOR_VALUE];
    [bColor set];
    [bluePath stroke];
}

@end
